package com.zhentao.controller;

import com.zhentao.model.dtos.ResponseResult;
import com.zhentao.model.wemedia.dto.WmMaterialDto;
import com.zhentao.model.wemedia.pojo.WmMaterial;
import com.zhentao.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    /**
     * 上传图片
     */
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) {
        return wmMaterialService.uploadPicture(multipartFile);
    }

    /**
     * 列表
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto materialDto) {
        return wmMaterialService.findList(materialDto);
    }

    /**
     * 收藏
     */
    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable("id") Integer id) {
        return wmMaterialService.collect(id);
    }

    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable("id") Integer id) {
        return wmMaterialService.cancelCollect(id);
    }
    /**
     * 删除
     */
    @GetMapping("/del_picture/{id}")
    public ResponseResult delPicture(@PathVariable("id") Integer id) {
        return wmMaterialService.delPicture(id);
    }




}
